<template>
  <div class="impcontain">
    <div class = 'msg_box' v-if='msgtest'>
      <div class="deatil_msg" >点击内容可查看内容具体详情</div>
    </div>
    <div class='rightsv' v-if='importseen'>
      <div class='rightmassage'>
        
        <div class='deatil_box' >
          <at-tooltip :content= "msg.asys_node_name" :placement="'top'">
            <div class='titleboxs'>
            {{msg.asys_node_name}}的详情
            </div>
          </at-tooltip>
          <div class = 'righttr'>
            <table class="deatil_message">
              <tr>
                <td style='height:50px;border-bottom:1px solid #eeeeee;color:#5c6781;font-size:12px;padding-left:20px;font-weight:bold'>节点详情</td>
                <td style='height:50px;border-bottom:1px solid #eeeeee;color:#5c67781;font-size:12px'></td>
              </tr>
              <tr>
                  <td class='impname'>系统节点名称</td>
                  <td class='impdata'>{{msg.asys_node_name}}</td>
              </tr>
              <tr>
                  <td class='impname'>系统节点代码</td>
                  <td class='impdata'>{{msg.asys_node_code}}</td>
              </tr>
              <tr>
                <td class='impname'>系统节点标签</td>
                <td class='impdata'>{{msg.asys_node_tag}}</td>
              </tr>
              <tr>
                <td class='impname'>节点类型</td>
                <td class='impdata'>{{msg.anode_type}}</td>
              </tr>
              <tr>
                <td class='impname'>操作系统</td>
                <td class='impdata'>{{msg.aoprate_system}}</td>
              </tr>
              <tr>
                <td class='impname'>等保级别</td>
                <td class='impdata'>{{msg.aconfi_lv_id}}</td>
              </tr>
              <tr>
                <td class='impname'>DNS</td>
                <td class='impdata'>{{msg.adns}}</td>
              </tr>
              <tr>
                <td class='impname'>维护人</td>
                <td class='impdata'>{{msg.amaintainer}}</td>
              </tr>
              <tr>
                <td class='impname'>维护人电话</td>
                <td class='impdata'>{{msg.amaintainer_phone}}</td>
              </tr>
              <tr>
                <td class='impname'>维护人邮箱</td>
                <td class='impdata'>{{msg.amaintainer_email}}</td>
              </tr>
              <tr>
                <td class='impname'>所属机构</td>
                <td class='impdata'>{{msg.cagency_name}}</td>
              </tr> 
              <tr>
                <td class='impname'>所属系统</td>
                <td class='impdata'>{{msg.binfo_sys_name}}</td>
              </tr>
                <tr>
                <td class='impname'>是否注册</td>
                <td class='impdata'>{{msg.ais_register}}</td>
              </tr>
              <tr>
                <td class='impname'>创建时间</td>
                <td class='impdata'>{{msg.ar_time}}</td>
              </tr>
              <tr>
                  <td class='impname'>系统节点描述</td>
                  <td class='impdata'>{{msg.asys_node_des}}</td>
              </tr>
            </table>
            <at-button class="return" @click='back' type='primary' >返回</at-button>
          </div>
        </div>
      </div>
    </div>
    <div class="leftsv">
      <div class='table_title'>系统节点列表</div>
      <div class="top" v-if="$route.query.type!=='readonly'">
        <at-button type='primary' style="float:left; margin-top:10px;width:110px;height:30px;border-radius:1px; margin-left:20px;position:relative;" @click="changeDetail()">
          <i class="saas-icon-page-refresh" style="position:absolute;top:5px;left:3px;font-size:20px" ></i>
          <span style='margin-right:-15px'>查看同步信息</span>  
        </at-button>
        <span v-if="num>0" :class="{'doubleNum':num.toString().length === 2, 'singleNum': num.toString().length === 1, 'more': num>99, 'common': true}"> 
          <span class="infoCount" v-if="num<=99"> {{num}}</span>  
          <span class="infoCount" v-else>99+</span>
        </span>
        <!-- <at-button type='primary' style="float:left; margin-top:10px;width:110px;height:30px;border-radius:1px; margin-left:20px;position:relative;" @click="newNode()">
          <i class="saas-icon-page-refresh" style="position:absolute;top:5px;left:3px;font-size:20px" ></i>
          <span style='margin-right:-20px'>上报未配置节点</span>  
        </at-button> -->
        <div class='searchBox'>
          <at-search class='search_input' 
                     project='mh' 
                     :placeholder='searchTitle' 
                     type="text" 
                     v-model='value' 
                     icon="search"  
                     @keyup.enter.native="handleIconClick"  
                     :on-icon-click="handleIconClick" ></at-search>
        </div>
      </div>
      <div class='table_box'> 
        <at-table 
        style="width:100%"  
        :data="tableBox.table" 
        @sort-change = "sortChange" 
        @cell-click='cellClick' 
        > 
        <at-table-column show-overflow-tooltip 
                         prop="asys_node_name" 
                         label="系统节点名称" 
                         min-width="100px"   >
        </at-table-column>  
        <at-table-column show-overflow-tooltip 
                         prop="asys_node_code" 
                         label="系统节点代码" 
                         min-width="90px" >
        </at-table-column>
        <at-table-column show-overflow-tooltip 
                         prop="anode_type" 
                         label="节点类型" 
                         min-width="90px" >
        </at-table-column>
        <at-table-column show-overflow-tooltip 
                         prop="aoprate_system" 
                         label="操作系统" 
                         min-width="80px" >
        </at-table-column>
        <at-table-column show-overflow-tooltip 
                         prop="aconfi_lv_id" 
                         label="等保级别" 
                         min-width="70px"
                        >
        </at-table-column>
        <at-table-column show-overflow-tooltip 
                         prop="cagency_name" 
                         label="所属机构" 
                         min-width="90px" >
        </at-table-column>
        <at-table-column show-overflow-tooltip 
                         prop="binfo_sys_name" 
                         label="所属系统" 
                         min-width="90px" >
        </at-table-column>
        <at-table-column show-overflow-tooltip 
                         prop="ar_time" 
                         label="创建时间" 
                         min-width="130px" 
                         sortable="custom">
        </at-table-column>
        <at-table-column show-overflow-tooltip 
                         prop="ais_register" 
                         label="是否注册" 
                         min-width="90px">
          <template slot-scope="scope">
            <span :style="scope.row.ais_register == '未注册' ?'color:red':'color:green'"
            >{{scope.row.ais_register}}</span>

          </template>
          
        </at-table-column>
        </at-table>
        <div style='text-align:center'>
          <Pagination 
          style="padding:20px;text-align: center;overflow:hidden;" 
          :currentPage="tableBox.tableData.pagination.current" 
          :total="tableBox.total" 
          :pageSizes="pageSizes" 
          :pageSize="tableBox.tableData.pagination.pageSize" 
          layout='total, sizes, prev, pager, next, jumper' 
          @current-change="handleCurrentChange" 
          @size-change="handleSizeChange">
          </Pagination> 
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { mapState } from 'vuex'
export default {
  name: 'important',
  data () {
    return {
      importseen: false,
      searchTitle: '请输入节点名称',
      msgtest: true,
      value: '',
      curentpage: 1,
      totalpage: 0,
      pageSize: 20,
      pageSizes: [20, 40, 60, 80]
    }
  },
  computed: {
    ...mapState({
      total: state => state.systemNode.total,
      tableBox: state => state.systemNode.tableBox,
      num: state => state.systemNode.num,
      msg: state => state.systemNode.msg
    })
  },
  created () {
    this.$store.dispatch('/systemNode/Gettable')
    this.init()
  },
  watch: {
    $route (to, from) {
      if (to.fullPath.includes('/business/basics/systemNode')) {
        this.init()
      }
    }
  },
  mounted () {
  },
  methods: {
    // 获取数据
    init () {
      this.tableBox.tableData.pagination.current = 1
      this.tableBox.tableData.search.value = ''
      this.$store.dispatch('/systemNode/Gettable')
    },
    // 展示详情
    cellClick (row, event) {
      this.$store.dispatch('/systemNode/returndata', { 'sys_node_id': row.asys_node_id })
      this.importseen = true
      this.msgtest = false
    },
    // 改变每页条数
    handleSizeChange (pageSizes) {
      this.$store.dispatch('/systemNode/Gettable', {
        type: 'pagSize',
        pageSizes: pageSizes
      })
    },
    // 分页
    handleCurrentChange (page) {
      this.$store.dispatch('/systemNode/Gettable', {
        type: 'pagCur',
        page: page
      })
    },
    // 搜索
    handleIconClick () {
      this.$store.dispatch('/systemNode/Gettable', {
        type: 'search',
        value: this.value,
        currentPage: this.currentPage
      })
    },
    // 排序
    sortChange ({ column, prop, order }) {
      if (order !== null) {
      } else {
        prop = 'amag_begin_time'
        order = 'ascending'
      }
      this.$store.dispatch('/systemNode/Gettable', {
        type: 'sorter',
        key: prop,
        value: order.slice(0, -3)
      })
    },
    // 变更详情点击
    changeDetail () {
      this.$router.push('/business/basics/systemNode/antosystemNode/')
    },
    // 上报未配置节点
    newNode () {
      this.$router.push('/business/basics/systemNode/newNode/')
    },
    // 返回
    back () {
      this.msgtest = true
      this.importseen = false
    }
  }
}
</script>    
<style lang='less'> 
.impcontain {
  margin-bottom: 30px;
  .at-table__body-wrapper {
    overflow: hidden;
  }
  .leftsv {
    background:#fff;
    margin-right:496px;
    border-top:none;
    border-right:solid 1px #eee;
  }
  .rightsv {
    min-width:478px;
    float:right;
    border:1px solid #eeeeee;
    border-top:none;
  }
  .msg_box {
    min-width:478px;
    float:right;
    border:1px solid #eeeeee;
    border-top:none;
    background: #ffffff;
    height:50px;
  }
  .titleboxs {
    // max-width: 434px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    height:50px;
    line-height:50px;
    padding-left:20px;
    border-bottom:1px solid #eeeeee;
    font-weight:bold;
    color:#5c6781;
    font-size:14px;
  }
  .deatil_msg {
    float:left;
    margin-top:15px;
    padding-left:20px
  }
  .deatil_box {
    background:#fff;
    width:478px;

  }
  .top {
    height:40px
  }
  .changeDetail {
    float:left; 
    margin-top:10px; 
    margin-bottom:10px;
    margin-left:20px;
    width:84px;
    height:30px;
    border-radius:1px;
  }
  .searchBox {
    float:right; 
    margin-top:9px; 
  }
  .search_input {
    margin-right:20px;
  }
  .table_box {
    margin-left:20px;
    margin-right:20px;
  }
  .msg_title {
    height:50px;
    border-bottom:solid 1px #eee;
    font-size:14px;
    color:#5c6781;
    padding-left:20px;
    padding-top:20px
  }
  .deatil_message {
    // width: 420px;
    margin-top:20px;
    margin: 20px auto;
    border:1px solid #eeeeee;
    table-layout: fixed;
  }
  .return {
    margin-left:210px;
    margin-bottom:20px;
  }
  .impname{
  width: 150px;
  height: 40px;
  padding-right:20px;
  text-align: right;
  background: #FFFFFF;
  font-size:12px;
  color:#8992a7
  }
  .impdata{
    word-wrap: break-word;
    height: 40px;
    width: 269px;
    padding-left: 20px;
    padding-right:20px;
    font-size:12px;
    color:#8992a7
  }
  .table_title {
    height:50px;
    line-height:50px;
    padding-left:20px;
    font-size:14px;
    font-weight:bold;
    color: #5c6781;
    border-bottom: 1px solid #eeeeee;
  }
  .doubleNum {
    width: 25px;
    margin-top: 4px;
    border-radius: 8.5px;
  }
  .singleNum {
    width: 17px;
    border-radius: 50%;
    top: -15px;
    position: relative;
    left: -14px;
  }
  .more {
    width: 32px;
    border-radius: 8.5px;
  }
  .common {
    font-weight: bold;
    background: #1f92ef;
    display: inline-block;
    height: 17px;
    position: relative;
    left: -8px;
    top: -8px;
  }
  .infoCount {
    display: block;
    color: #FFFFFF;
    height: 102px;
    line-height: 0px;
    text-align: center;
    font-size : 12px;
    -webkit-transform : scale(0.84,0.84) ;
    *font-size:10px;
  }
}
</style>